package com.sl.mapper;

import com.sl.pojo.CompanyCheck;
import com.sl.vo.CheckInfoVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

public interface CompanyCheckMapper extends Mapper<CompanyCheck> {


    /**
     * 查询每月检查的企业信息
     * @param firstDay
     * @param lastDay
     * @return
     */
    @Select("SELECT cc.company_name,cc.company_address,cc.users,cc.legal_person,cc.`level`,cc.description,cc.check_time\n" +
            "FROM sl_company_check cc WHERE check_time BETWEEN #{firstDay} AND #{lastDay}")
    public List<Map> findListByMonth(@Param("firstDay")LocalDate firstDay, @Param("lastDay")LocalDate lastDay);


    /**
     * 通过企业的数目。`level`='A' OR `level`='B'  .需要可以加
     * @return
     */
    @Select("SELECT count(*) FROM " +
            "(SELECT * FROM sl_company_check cc WHERE check_time BETWEEN #{firstDay} AND #{lastDay})ss " +
            " WHERE `level` IN ('A','B')")
    public Integer passCompanyTotal(@Param("firstDay")LocalDate firstDay, @Param("lastDay")LocalDate lastDay);


    @Select("")
    public CheckInfoVO findCompany();
}
